﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for SoftwareDTO
/// </summary>
public class SoftwareDTO
{
    public string Money
    {
        get {
            if (price > 0)
                return "$" + MyFunction.moneyToString(price) + "vnđ";
            else
                return "Free";
        }
        set {
            price = 0;
            try
            {
                int.Parse(value);
            }
            catch
            {
                price = 0;
            }
        }
    }
    private string name;
    private string version;
    private DateTime dateUp;
    private DateTime dateUpdrade;
    private double size;
    private string acountUp;
    private string company;
    private int catalogID;
    private int price;
    private string infoNewVersion;
    private string info;
    private int download1;
    private int download2;
    private int rate1;
    private int rate2;
    private int rate3;
    private int rate4;
    private int rate5;
    private float rating;

    public float Rating
    {
        get {
            float a = (float)((rate5 * 5 + rate4 * 4 + rate3 * 3 + Rate2 * 2 + Rate1) * 5) / ((rate5 + rate4 + Rate3 + Rate2 + rate2) * 5);
            return (float)Math.Round(a, 2) ;
         }
        set { rating = value; }
    }
    private float star;

    public float Star
    {
        get {
            float rate = Rating;
            float ext = rate % 1;
            if (ext < 0.5f)
                ext = 0.5f;
            else
                ext = 1;

            return (float)((int)rate+ext);
            
        }
        set { star = value; }
    }
    private string link;
    private string icon;
    private string tagSearch;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }
    public string Version
    {
        get { return version; }
        set { version = value; }
    }
    public DateTime DateUp
    {
        get { return dateUp; }
        set { dateUp = value; }
    }
    public DateTime DateUpdrade
    {
        get { return dateUpdrade; }
        set { dateUpdrade = value; }
    }
    public double Size
    {
        get { return size; }
        set { size = value; }
    }
    public string AcountUp
    {
        get { return acountUp; }
        set { acountUp = value; }
    }
    public string Company
    {
        get { return company; }
        set { company = value; }
    }
    public int CatalogID
    {
        get { return catalogID; }
        set { catalogID = value; }
    }
    public int Price
    {
        get { return price; }
        set { price = value; }
    }
    public string InfoNewVersion
    {
        get { return infoNewVersion; }
        set { infoNewVersion = value; }
    }
    public string Info
    {
        get { return info; }
        set { info = value; }
    }
    public int Download1
    {
        get { return download1; }
        set { download1 = value; }
    }
    public int Download2
    {
        get { return download2; }
        set { download2 = value; }
    }
    public int Rate1
    {
        get { return rate1; }
        set { rate1 = value; }
    }
    public int Rate2
    {
        get { return rate2; }
        set { rate2 = value; }
    }
    public int Rate3
    {
        get { return rate3; }
        set { rate3 = value; }
    }
    public int Rate4
    {
        get { return rate4; }
        set { rate4 = value; }
    }
    public int Rate5
    {
        get { return rate5; }
        set { rate5 = value; }
    }
    public string Link
    {
        get { return link; }
        set { link = value; }
    }
    public string Icon
    {
        get { return icon; }
        set { icon = value; }
    }
    public string TagSearch
    {
        get { return tagSearch; }
        set { tagSearch = value; }
    }
	public SoftwareDTO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
   
}